import GameEntity from './gameEntity.js';

export default class PlayerEntity extends GameEntity {
    constructor(x, y, width, height, color) {
        super(x, y, width, height, color);
        this.speed = 5;
    }

    update(keyStates, mouse) {
        if (keyStates['ArrowLeft'] && this.x > 0) {
            this.x -= this.speed;
        }
        if (keyStates['ArrowRight'] && this.x + this.width < window.gameEngine.canvas.width) {
            this.x += this.speed;
        }
        if (keyStates['ArrowUp'] && this.y > 0) {
            this.y -= this.speed;
        }
        if (keyStates['ArrowDown'] && this.y + this.height < window.gameEngine.canvas.height) {
            this.y += this.speed;
        }
    }
}    